cmake_minimum_required(VERSION 3.5)

project(CMakeTemplateQT5 VERSION 0.1 LANGUAGES CXX)

add_compile_options( "/utf-8" ) # warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失 
add_compile_options( "/MP" ) # 多线程编译

SET(CMAKE_BUILD_TYPE "Debug")  # Release

add_definitions( -D_WIN32_WINNT=0x0A00 )

list(APPEND CMAKE_PREFIX_PATH "E:/bigdata/Qt5.12.12/5.12.12/msvc2017_64/lib/cmake")
# list(APPEND CMAKE_PREFIX_PATH "F:/auxiliary/vcpkg2024vsg-gl3-all/installed/x64-windows/share/fmt")
# list(APPEND CMAKE_PREFIX_PATH "F:/auxiliary/vcpkg2024vsg-gl3-all/installed/x64-windows/share/spdlog")


# spdlog
find_package( spdlog REQUIRED )

# fmt
find_package( fmt REQUIRED )


# include_directories("E:/bigdata/LibCPP/OpenSceneGraph-3.6.5-VC2022-64-Debug-2023-01/include")
include_directories("D:/Project/CPlusPlus/TechResearch/CMakeTemplateQT5/src/threeParty/fmt_x64-windows/include")
include_directories("D:/Project/CPlusPlus/TechResearch/CMakeTemplateQT5/src/threeParty/spdlog_x64-windows/include")
include_directories("D:/Project/CPlusPlus/TechResearch/CMakeTemplateQT5/src/threeParty/asyncplusplus_x64-windows/include")
include_directories("D:/Project/CPlusPlus/TechResearch/CMakeTemplateQT5/src/threeParty/qtpropertybrowserExt")

#Output
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/output/lib) #  lib
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/output/bin)


set(CMAKE_INCLUDE_CURRENT_DIR ON)
#
set( SOURCES_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/src" )
set( SOURCES_QTPROPERTYBROWSER "${CMAKE_CURRENT_SOURCE_DIR}/src/threeParty/qtpropertybrowserExt" )
set( DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/data" )
set( CONFIG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/config" )
#
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
#
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#
find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets LinguistTools Sql  OpenGL REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets LinguistTools Sql  OpenGL REQUIRED)
#
set(TS_FILE_LIST ${SOURCES_ROOT}/CMakeTemplateQT5_zh_CN.ts)
#
include_directories(
  ${SOURCES_ROOT}
  ${SOURCES_QTPROPERTYBROWSER}
)

set(INCLUDE_FILE_LIST 
  #
  ${SOURCES_ROOT}/MainWindow.h
  ${SOURCES_QTPROPERTYBROWSER}/qtbuttonpropertybrowser.h
  ${SOURCES_QTPROPERTYBROWSER}/qteditorfactory.h
  ${SOURCES_QTPROPERTYBROWSER}/qtgroupboxpropertybrowser.h
  ${SOURCES_QTPROPERTYBROWSER}/qtpropertybrowser.h
  ${SOURCES_QTPROPERTYBROWSER}/qtpropertybrowserutils_p.h
  ${SOURCES_QTPROPERTYBROWSER}/qtpropertymanager.h
  ${SOURCES_QTPROPERTYBROWSER}/qttreepropertybrowser.h
  ${SOURCES_QTPROPERTYBROWSER}/qtvariantproperty.h
  ${SOURCES_QTPROPERTYBROWSER}/PixmapSelectedWidget.h
  #
  #  
)

set(SOURCE_FILE_LIST 
  ${SOURCES_ROOT}/main.cpp
  ${SOURCES_ROOT}/MainWindow.cpp
  ${SOURCES_QTPROPERTYBROWSER}/qtbuttonpropertybrowser.cpp
  ${SOURCES_QTPROPERTYBROWSER}/qteditorfactory.cpp
  ${SOURCES_QTPROPERTYBROWSER}/qtgroupboxpropertybrowser.cpp
  ${SOURCES_QTPROPERTYBROWSER}/qtpropertybrowser.cpp
  ${SOURCES_QTPROPERTYBROWSER}/qtpropertybrowserutils.cpp
  ${SOURCES_QTPROPERTYBROWSER}/qtpropertymanager.cpp
  ${SOURCES_QTPROPERTYBROWSER}/qttreepropertybrowser.cpp
  ${SOURCES_QTPROPERTYBROWSER}/qtvariantproperty.cpp
  ${SOURCES_QTPROPERTYBROWSER}/PixmapSelectedWidget.cpp
)

set(RESOURCE_FILE_LIST  
  ${SOURCES_ROOT}/Components.qrc
  ${SOURCES_QTPROPERTYBROWSER}/qtpropertybrowser.qrc
)
#qt_add_resources(SOURCE_FILE_LIST ${RESOURCE_FILE_LIST})


set(PROJECT_SOURCES
  ${INCLUDE_FILE_LIST}  
  ${SOURCE_FILE_LIST}
  ${RESOURCE_FILE_LIST}
  ${TS_FILE_LIST}
)

if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
    qt_add_executable(CMakeTemplateQT5  MANUAL_FINALIZATION  ${PROJECT_SOURCES})

    qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
else()    
    add_executable(CMakeTemplateQT5  ${PROJECT_SOURCES})    

    qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
endif()

target_link_directories( CMakeTemplateQT5 PRIVATE
  # E:/bigdata/LibCPP/OpenSceneGraph-3.6.5-VC2022-64-Debug-2023-01/lib
  # F:/auxiliary/vcpkg2024vsg-gl3-all/installed/x64-windows/debug/lib
  #D:/Project/CPlusPlus/TechResearch/CMakeTemplateQT5/src/threeParty/qtpropertybrowser/lib
  D:/Project/CPlusPlus/TechResearch/CMakeTemplateQT5/src/threeParty/spdlog_x64-windows/debug/lib
  D:/Project/CPlusPlus/TechResearch/CMakeTemplateQT5/src/threeParty/fmt_x64-windows/debug/lib
  D:/Project/CPlusPlus/TechResearch/CMakeTemplateQT5/src/threeParty/asyncplusplus_x64-windows/debug/lib
)

target_link_libraries( CMakeTemplateQT5 PRIVATE Qt${QT_VERSION_MAJOR}::Widgets   
  # fmt::fmt
  # spdlog::spdlog
  #QtSolutions_PropertyBrowser-headd
  fmtd
  spdlogd
  async++
)

target_link_libraries(CMakeTemplateQT5 PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)

set_target_properties(CMakeTemplateQT5 PROPERTIES WIN32_EXECUTABLE TRUE )

if(QT_VERSION_MAJOR EQUAL 6)
    qt_finalize_executable(CMakeTemplateQT5)
endif()
